<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title>Axios-get</title>
	</head>
	<body>
		<!-- 使用    {params:js对象}  传参 -->
		<div id="app">




		</div>

		<script src="../js/axios.js"></script>
		<script>
			/* *
			 需求 对象方式的数据传递
			 
			 axios.get(url,'参数').then(回调函数)
			 */
			let url = `http://127.0.0.1:8090/axios/user`
			let id = 1
			let name = '黑熊精'
			let age = 3000
			let sex = '男'
			let user = {
				// id:id,
				name: name,
				age: age,
				sex: sex
			}


               //全不行
			// let passData = `"id":"${id}","name":"${name}","age":"${age}","sex":"${sex}"`
			// let passData = `"name":"${name}","age":"${age}","sex":"${sex}"`
			// let passData = `name=${name}&age=${age}&sex=${sex}`
			// axios.get(url, passData)
			// 	.then(function(result) {
			// 	console.log(result.data)
			// })
			
			//get不能传json串 param传参不能用restFul风格
			axios.get(url, {//key:value key固定写法 params 参数对象
				params: user})
				.then(function(result) {
				console.log(result.data)
			})
			
			
			
			
		</script>
	</body>
</html>
